<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
   
   <meta name="description" content="string operations">
    
    <meta name="author" content="John S. Urban" >
    <link rel="icon" href="../favicon.png">

    <title>isNumber &ndash; M_strings</title>

    <link href="../css/bootstrap.min.css" rel="stylesheet">
    <link href="../css/pygments.css" rel="stylesheet">
    <link href="../css/font-awesome.min.css" rel="stylesheet">
    <link href="../css/local.css" rel="stylesheet">
    
    <link  href="../tipuesearch/tipuesearch.css" rel="stylesheet">
    
    

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
    
    <script src="../js/jquery-2.1.3.min.js"></script>
    <script src="../js/svg-pan-zoom.min.js"></script>

  </head>

  <body>

    <!-- Fixed navbar -->
    <nav class="navbar navbar-inverse navbar-fixed-top">
      <div class="container">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="../index.html">M_strings </a>
        </div>
        <div id="navbar" class="navbar-collapse collapse">
          <ul class="nav navbar-nav">
        
            <li class="dropdown hidden-xs visible-sm visible-md hidden-lg">
              <a href="#" class="dropdown-toggle"
              data-toggle="dropdown" role="button"
              aria-haspopup="true"
     aria-expanded="false">Contents <span class="caret"></span></a>
        <ul class="dropdown-menu">
          
              
            <li><a href="../lists/files.html">Source Files</a></li>
        
        
        
            <li><a href="../lists/modules.html">Modules</a></li>
        
            
                                
            <li><a href="../lists/procedures.html">Procedures</a></li>
        
               
            <li><a href="../lists/types.html">Derived Types</a></li>
        
        
            </ul>
            </li>


<li class="visible-xs hidden-sm visible-lg"><a href="../lists/files.html">Source Files</a></li>



<li class="visible-xs hidden-sm visible-lg"><a href="../lists/modules.html">Modules</a></li>



<li class="visible-xs hidden-sm visible-lg"><a href="../lists/procedures.html">Procedures</a></li>

                             
<li class="visible-xs hidden-sm visible-lg"><a href="../lists/types.html">Derived Types</a></li>


          </ul>
        
        <form action="../search.html" class="navbar-form navbar-right" role="search">
        <div class="form-group">
          <input type="text" class="form-control" placeholder="Search" name="q" id="tipue_search_input" autocomplete="off" required>
        </div>
<!--
        <button type="submit" class="btn btn-default">Submit</button>
-->
        </form>
        
        </div><!--/.nav-collapse -->
      </div>
    </nav>

    <div class="container">
    
  
  <div class="row">
    <h1>isNumber
      <small>Function</small>
    
    </h1>
    
<div class="row">
  <div class="col-lg-12">
<div class="well well-sm">
  <ul class="list-inline" style="margin-bottom:0px;display:inline">
     
     
     
     
    
    
     <li><i class="fa fa-list-ol"></i>
       <a data-toggle="tooltip"
    data-placement="bottom" data-html="true"
    title=" 4.6% of total for procedures.">114 statements</a>
     </li> 
     
     
     
    <li><i class="fa fa-code"></i><a href="../src/M_strings.f90"> Source File</a></li>
     
     
  </ul>
  <ol class="breadcrumb in-well text-right">
  
    
     <li><a href='../sourcefile/m_strings.f90.html'>M_strings.f90</a></li>
    
     <li><a href='../module/m_strings.html'>M_strings</a></li>
    
  
     <li class="active">isNumber</li>
  </ol>
</div>
</div>
</div>
<script>
  $(function () {
  $('[data-toggle="tooltip"]').tooltip()
  })
</script>

  </div>
  
  <div class="row">
    <div class="col-md-3 hidden-xs hidden-sm visible-md visible-lg">
    
<div id="sidebar">
  
<h3>Contents</h3>
 



<div class="panel panel-primary">
  <div class="panel-heading text-left"><h3 class="panel-title"><a data-toggle="collapse" href="#vars-0">Variables</a></h3></div>
  <div id="vars-0" class="panel-collapse collapse">
    <div class="list-group">
      
      <a class="list-group-item" href="../proc/isnumber.html#variable-founddigit">founddigit</a>
      
      <a class="list-group-item" href="../proc/isnumber.html#variable-i~10">i</a>
      
      <a class="list-group-item" href="../proc/isnumber.html#variable-iend~2">iend</a>
      
      <a class="list-group-item" href="../proc/isnumber.html#variable-message">message</a>
      
      <a class="list-group-item" href="../proc/isnumber.html#variable-verbose_local">verbose_local</a>
      
      <a class="list-group-item" href="../proc/isnumber.html#variable-z">z</a>
      
    </div>
  </div>
</div>













<div class="panel panel-primary">
  <div class="panel-heading text-left"><h3 class="panel-title"><a data-toggle="collapse" href="#subs-0">Subroutines</a></h3></div>
  <div class="list-group">
    <div id="subs-0" class="panel-collapse collapse">
      
      <a class="list-group-item" href="../proc/isnumber.html#proc-next">next</a>
      
    </div>
  </div>
</div>









<div class="panel panel-primary">
  <div class="panel-heading text-left"><h3 class="panel-title">Source Code</h3></div>
  <div class="list-group">
    <a class="list-group-item" href="../proc/isnumber.html#src">isNumber</a>
  </div>
</div>



</div>

    </div>
    
    <div class="col-md-9" id='text'>
    <h2>
public function isNumber(string, msg, verbose) result(isnumber)
    
    
   
</h2>
    
  


    
    <h2 id="name">NAME</h2>
<div class="codehilite"><pre><span></span><code><span class="nv">isnumber</span><span class="ss">(</span><span class="mi">3</span><span class="nv">f</span><span class="ss">)</span> <span class="o">-</span> [<span class="nv">M_strings</span>:<span class="nv">NUMERIC</span>] <span class="nv">determine</span> <span class="k">if</span> <span class="nv">a</span> <span class="nv">string</span> <span class="nv">represents</span> <span class="nv">a</span> <span class="nv">number</span>
<span class="ss">(</span><span class="nv">LICENSE</span>:<span class="nv">PD</span><span class="ss">)</span>
</code></pre></div>

<h2 id="synopsis">SYNOPSIS</h2>
<div class="codehilite"><pre><span></span><code><span class="k">function</span><span class="w"> </span><span class="nf">isnumber</span><span class="p">(</span>str,msg<span class="p">)</span><span class="w"></span>

<span class="w"> </span><span class="n">character</span><span class="p">(</span><span class="n">len</span><span class="p">=</span><span class="o">*</span><span class="p">),</span><span class="n">intent</span><span class="p">(</span><span class="n">in</span><span class="p">)</span><span class="w">  </span><span class="p">::</span><span class="w"> </span><span class="n">str</span><span class="w"></span>
<span class="w"> </span><span class="n">character</span><span class="p">(</span><span class="n">len</span><span class="p">=:),</span><span class="n">intent</span><span class="p">(</span><span class="n">out</span><span class="p">),</span><span class="n">allocatable</span><span class="p">,</span><span class="n">optional</span><span class="w">  </span><span class="p">::</span><span class="w"> </span><span class="n">msg</span><span class="w"></span>
</code></pre></div>

<h2 id="description">DESCRIPTION</h2>
<div class="codehilite"><pre><span></span><code> <span class="nv">ISNUMBER</span><span class="ss">(</span><span class="mi">3</span><span class="nv">f</span><span class="ss">)</span> <span class="nv">returns</span> <span class="nv">a</span> <span class="nv">value</span> <span class="nv">greater</span> <span class="nv">than</span> <span class="nv">zero</span> <span class="k">if</span> <span class="nv">the</span> <span class="nv">string</span> <span class="nv">represents</span>
 <span class="nv">a</span> <span class="nv">number</span>, <span class="nv">and</span> <span class="nv">a</span> <span class="nv">number</span> <span class="nv">less</span> <span class="nv">than</span> <span class="nv">or</span> <span class="nv">equal</span> <span class="nv">to</span> <span class="nv">zero</span> <span class="k">if</span> <span class="nv">it</span> <span class="nv">is</span> <span class="nv">a</span> <span class="nv">bad</span> <span class="nv">number</span>.
 <span class="nv">Blank</span> <span class="nv">characters</span> <span class="nv">are</span> <span class="nv">ignored</span>.
</code></pre></div>

<h2 id="options">OPTIONS</h2>
<div class="codehilite"><pre><span></span><code> str  the string to evaluate as to whether it represents a numeric value
      or not
 msg  An optional message describing the string
</code></pre></div>

<h2 id="returns">RETURNS</h2>
<div class="codehilite"><pre><span></span><code><span class="w"> </span><span class="n">isnumber</span><span class="w">  </span><span class="n">the</span><span class="w"> </span><span class="n">following</span><span class="w"> </span><span class="k">values</span><span class="w"> </span><span class="k">are</span><span class="w"> </span><span class="n">returned</span><span class="w"></span>

<span class="w">            </span><span class="mi">1</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">an</span><span class="w"> </span><span class="k">integer</span><span class="w">             </span><span class="o">[</span><span class="n">-+</span><span class="o">]</span><span class="n">NNNNN</span><span class="w"></span>
<span class="w">            </span><span class="mi">2</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">a</span><span class="w"> </span><span class="n">whole</span><span class="w"> </span><span class="n">number</span><span class="w">         </span><span class="o">[</span><span class="n">-+</span><span class="o">]</span><span class="n">NNNNN</span><span class="p">.</span><span class="w"></span>
<span class="w">            </span><span class="mi">3</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">a</span><span class="w"> </span><span class="nc">real</span><span class="w"> </span><span class="k">value</span><span class="w">           </span><span class="o">[</span><span class="n">-+</span><span class="o">]</span><span class="n">NNNNN</span><span class="p">.</span><span class="n">MMMM</span><span class="w"></span>
<span class="w">            </span><span class="mi">4</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">a</span><span class="w"> </span><span class="n">exponential</span><span class="w"> </span><span class="k">value</span><span class="w">    </span><span class="o">[</span><span class="n">-+</span><span class="o">]</span><span class="n">NNNNN</span><span class="p">.</span><span class="n">MMMM</span><span class="o">[</span><span class="n">-+</span><span class="o">]</span><span class="n">LLLL</span><span class="w"></span>
<span class="w">                                         </span><span class="o">[</span><span class="n">-+</span><span class="o">]</span><span class="n">NNNNN</span><span class="p">.</span><span class="n">MMMM</span><span class="o">[</span><span class="n">ed</span><span class="o">][</span><span class="n">-+</span><span class="o">]</span><span class="n">LLLL</span><span class="w"></span>

<span class="w">           </span><span class="k">values</span><span class="w"> </span><span class="k">less</span><span class="w"> </span><span class="k">than</span><span class="w"> </span><span class="mi">1</span><span class="w"> </span><span class="n">represent</span><span class="w"> </span><span class="n">an</span><span class="w"> </span><span class="n">error</span><span class="w"></span>
</code></pre></div>

<h2 id="examples">EXAMPLES</h2>
<p>As the example shows, you can use an internal READ(3f) along with the
   IOSTAT= parameter to check (and read) a string as well.</p>
<div class="codehilite"><pre><span></span><code> <span class="nv">program</span> <span class="nv">demo_isnumber</span>
 <span class="nv">use</span> <span class="nv">M_strings</span>, <span class="nv">only</span> : <span class="nv">isnumber</span>
 <span class="nv">implicit</span> <span class="nv">none</span>
 <span class="nv">character</span><span class="ss">(</span><span class="nv">len</span><span class="o">=</span><span class="mi">256</span><span class="ss">)</span> :: <span class="nv">line</span>
 <span class="nv">real</span>               :: <span class="nv">value</span>
 <span class="nv">integer</span>            :: <span class="nv">ios1</span>, <span class="nv">ios2</span>
 <span class="nv">integer</span>            :: <span class="nv">answer</span>
 <span class="nv">character</span><span class="ss">(</span><span class="nv">len</span><span class="o">=</span><span class="mi">256</span><span class="ss">)</span> :: <span class="nv">message</span>
 <span class="nv">character</span><span class="ss">(</span><span class="nv">len</span><span class="o">=</span>:<span class="ss">)</span>,<span class="nv">allocatable</span> :: <span class="nv">description</span>
    <span class="nv">write</span><span class="ss">(</span><span class="o">*</span>,<span class="o">*</span><span class="ss">)</span><span class="s1">&#39;</span><span class="s">Begin entering values, one per line</span><span class="s1">&#39;</span>
    <span class="k">do</span>
       <span class="nv">read</span><span class="ss">(</span><span class="o">*</span>,<span class="s1">&#39;</span><span class="s">(a)</span><span class="s1">&#39;</span>,<span class="nv">iostat</span><span class="o">=</span><span class="nv">ios1</span><span class="ss">)</span><span class="nv">line</span>
       <span class="o">!</span>
       <span class="o">!</span> <span class="nv">try</span> <span class="nv">string</span> <span class="nv">as</span> <span class="nv">number</span> <span class="nv">using</span> <span class="nv">list</span><span class="o">-</span><span class="nv">directed</span> <span class="nv">input</span>
       <span class="nv">line</span><span class="o">=</span><span class="s1">&#39;&#39;</span>
       <span class="nv">read</span><span class="ss">(</span><span class="nv">line</span>,<span class="o">*</span>,<span class="nv">iostat</span><span class="o">=</span><span class="nv">ios2</span>,<span class="nv">iomsg</span><span class="o">=</span><span class="nv">message</span><span class="ss">)</span> <span class="nv">value</span>
       <span class="k">if</span><span class="ss">(</span><span class="nv">ios2</span>.<span class="nv">eq</span>.<span class="mi">0</span><span class="ss">)</span><span class="k">then</span>
          <span class="nv">write</span><span class="ss">(</span><span class="o">*</span>,<span class="o">*</span><span class="ss">)</span><span class="s1">&#39;</span><span class="s">VALUE=</span><span class="s1">&#39;</span>,<span class="nv">value</span>
       <span class="k">elseif</span><span class="ss">(</span> <span class="nv">is_iostat_end</span><span class="ss">(</span><span class="nv">ios1</span><span class="ss">)</span> <span class="ss">)</span> <span class="k">then</span>
          <span class="nv">stop</span> <span class="s1">&#39;</span><span class="s">end of file</span><span class="s1">&#39;</span>
       <span class="k">else</span>
          <span class="nv">write</span><span class="ss">(</span><span class="o">*</span>,<span class="o">*</span><span class="ss">)</span><span class="s1">&#39;</span><span class="s">ERROR:</span><span class="s1">&#39;</span>,<span class="nv">ios2</span>,<span class="nv">trim</span><span class="ss">(</span><span class="nv">message</span><span class="ss">)</span>
       <span class="k">endif</span>
       <span class="o">!</span>
       <span class="o">!</span> <span class="nv">try</span> <span class="nv">string</span> <span class="nv">using</span> <span class="nv">isnumber</span><span class="ss">(</span><span class="mi">3</span><span class="nv">f</span><span class="ss">)</span>
       <span class="nv">answer</span><span class="o">=</span><span class="nv">isnumber</span><span class="ss">(</span><span class="nv">line</span>,<span class="nv">msg</span><span class="o">=</span><span class="nv">description</span><span class="ss">)</span>
       <span class="k">if</span><span class="ss">(</span><span class="nv">answer</span>.<span class="nv">gt</span>.<span class="mi">0</span><span class="ss">)</span><span class="k">then</span>
          <span class="nv">write</span><span class="ss">(</span><span class="o">*</span>,<span class="o">*</span><span class="ss">)</span> <span class="o">&amp;</span>
          <span class="o">&amp;</span> <span class="s1">&#39;</span><span class="s"> for </span><span class="s1">&#39;</span>,<span class="nv">trim</span><span class="ss">(</span><span class="nv">line</span><span class="ss">)</span>,<span class="s1">&#39;</span><span class="s"> </span><span class="s1">&#39;</span>,<span class="nv">answer</span>,<span class="s1">&#39;</span><span class="s">:</span><span class="s1">&#39;</span>,<span class="nv">description</span>
       <span class="k">else</span>
          <span class="nv">write</span><span class="ss">(</span><span class="o">*</span>,<span class="o">*</span><span class="ss">)</span> <span class="o">&amp;</span>
          <span class="o">&amp;</span> <span class="s1">&#39;</span><span class="s"> ERROR for </span><span class="s1">&#39;</span>,<span class="nv">trim</span><span class="ss">(</span><span class="nv">line</span><span class="ss">)</span>,<span class="s1">&#39;</span><span class="s"> </span><span class="s1">&#39;</span>,<span class="nv">answer</span>,<span class="s1">&#39;</span><span class="s">:</span><span class="s1">&#39;</span>,<span class="nv">description</span>
       <span class="k">endif</span>
       <span class="o">!</span>
    <span class="nv">enddo</span>
 <span class="k">end</span> <span class="nv">program</span> <span class="nv">demo_isnumber</span>
</code></pre></div>

<p>Example run</p>
<div class="codehilite"><pre><span></span><code><span class="o">&gt;</span> <span class="nv">Begin</span> <span class="nv">entering</span> <span class="nv">values</span>
<span class="o">&gt;</span> <span class="nv">ERROR</span>:          <span class="o">-</span><span class="mi">1</span> <span class="k">End</span> <span class="nv">of</span> <span class="nv">file</span>
<span class="o">&gt;</span>  <span class="nv">ERROR</span> <span class="k">for</span>            <span class="o">-</span><span class="mi">1</span> :<span class="nv">null</span> <span class="nv">string</span>
<span class="o">&gt;</span><span class="mi">10</span>
<span class="o">&gt;</span> <span class="nv">VALUE</span><span class="o">=</span>   <span class="mi">10</span>.<span class="mi">0000000</span>
<span class="o">&gt;</span>  <span class="k">for</span> <span class="mi">10</span>            <span class="mi">1</span> :<span class="nv">integer</span>
<span class="o">&gt;</span><span class="mi">20</span>
<span class="o">&gt;</span> <span class="nv">VALUE</span><span class="o">=</span>   <span class="mi">20</span>.<span class="mi">0000000</span>
<span class="o">&gt;</span>  <span class="k">for</span> <span class="mi">20</span>            <span class="mi">1</span> :<span class="nv">integer</span>
<span class="o">&gt;</span><span class="mi">20</span>.
<span class="o">&gt;</span> <span class="nv">VALUE</span><span class="o">=</span>   <span class="mi">20</span>.<span class="mi">0000000</span>
<span class="o">&gt;</span>  <span class="k">for</span> <span class="mi">20</span>.            <span class="mi">2</span> :<span class="nv">whole</span> <span class="nv">number</span>
<span class="o">&gt;</span><span class="mi">30</span>.<span class="mi">1</span>
<span class="o">&gt;</span> <span class="nv">VALUE</span><span class="o">=</span>   <span class="mi">30</span>.<span class="mi">1000004</span>
<span class="o">&gt;</span>  <span class="k">for</span> <span class="mi">30</span>.<span class="mi">1</span>            <span class="mi">3</span> :<span class="nv">real</span> <span class="nv">number</span>
<span class="o">&gt;</span><span class="mi">3</span><span class="nv">e1</span>
<span class="o">&gt;</span> <span class="nv">VALUE</span><span class="o">=</span>   <span class="mi">30</span>.<span class="mi">0000000</span>
<span class="o">&gt;</span>  <span class="k">for</span> <span class="mi">3</span><span class="nv">e1</span>            <span class="mi">4</span> :<span class="nv">value</span> <span class="nv">with</span> <span class="nv">exponent</span>
<span class="o">&gt;</span><span class="mi">1</span><span class="o">-</span><span class="mi">2</span>
<span class="o">&gt;</span> <span class="nv">VALUE</span><span class="o">=</span>   <span class="mi">9</span>.<span class="mi">99999978</span><span class="nv">E</span><span class="o">-</span><span class="mi">03</span>
<span class="o">&gt;</span>  <span class="k">for</span> <span class="mi">1</span><span class="o">-</span><span class="mi">2</span>            <span class="mi">4</span> :<span class="nv">value</span> <span class="nv">with</span> <span class="nv">exponent</span>
<span class="o">&gt;</span><span class="mi">100</span>.<span class="mi">22</span><span class="nv">d</span><span class="o">-</span><span class="mi">4</span>
<span class="o">&gt;</span> <span class="nv">VALUE</span><span class="o">=</span>   <span class="mi">1</span>.<span class="mi">00220004</span><span class="nv">E</span><span class="o">-</span><span class="mi">02</span>
<span class="o">&gt;</span>  <span class="k">for</span> <span class="mi">100</span>.<span class="mi">22</span><span class="nv">d</span><span class="o">-</span><span class="mi">4</span>            <span class="mi">4</span> :<span class="nv">value</span> <span class="nv">with</span> <span class="nv">exponent</span>
<span class="o">&gt;</span><span class="mi">1</span><span class="o">--</span><span class="mi">2</span>
<span class="o">&gt;</span> <span class="nv">ERROR</span>:        <span class="mi">5010</span> <span class="nv">Bad</span> <span class="nv">real</span> <span class="nv">number</span> <span class="nv">in</span> <span class="nv">item</span> <span class="mi">1</span> <span class="nv">of</span> <span class="nv">list</span> <span class="nv">input</span>
<span class="o">&gt;</span>  <span class="nv">ERROR</span> <span class="k">for</span> <span class="mi">1</span><span class="o">--</span><span class="mi">2</span>           <span class="o">-</span><span class="mi">5</span> :<span class="nv">bad</span> <span class="nv">number</span>
<span class="o">&gt;</span><span class="nv">e</span>
<span class="o">&gt;</span> <span class="nv">ERROR</span>:        <span class="mi">5010</span> <span class="nv">Bad</span> <span class="nv">real</span> <span class="nv">number</span> <span class="nv">in</span> <span class="nv">item</span> <span class="mi">1</span> <span class="nv">of</span> <span class="nv">list</span> <span class="nv">input</span>
<span class="o">&gt;</span>  <span class="nv">ERROR</span> <span class="k">for</span> <span class="nv">e</span>           <span class="o">-</span><span class="mi">6</span> :<span class="nv">missing</span> <span class="nv">leading</span> <span class="nv">value</span> <span class="nv">before</span> <span class="nv">exponent</span>
<span class="o">&gt;</span><span class="nv">e1</span>
<span class="o">&gt;</span> <span class="nv">ERROR</span>:        <span class="mi">5010</span> <span class="nv">Bad</span> <span class="nv">real</span> <span class="nv">number</span> <span class="nv">in</span> <span class="nv">item</span> <span class="mi">1</span> <span class="nv">of</span> <span class="nv">list</span> <span class="nv">input</span>
<span class="o">&gt;</span>  <span class="nv">ERROR</span> <span class="k">for</span> <span class="nv">e1</span>           <span class="o">-</span><span class="mi">6</span> :<span class="nv">missing</span> <span class="nv">leading</span> <span class="nv">value</span> <span class="nv">before</span> <span class="nv">exponent</span>
<span class="o">&gt;</span><span class="mi">1</span><span class="nv">e</span>
<span class="o">&gt;</span> <span class="nv">ERROR</span>:        <span class="mi">5010</span> <span class="nv">Bad</span> <span class="nv">real</span> <span class="nv">number</span> <span class="nv">in</span> <span class="nv">item</span> <span class="mi">1</span> <span class="nv">of</span> <span class="nv">list</span> <span class="nv">input</span>
<span class="o">&gt;</span>  <span class="nv">ERROR</span> <span class="k">for</span> <span class="mi">1</span><span class="nv">e</span>           <span class="o">-</span><span class="mi">3</span> :<span class="nv">missing</span> <span class="nv">exponent</span>
<span class="o">&gt;</span><span class="mi">1</span><span class="nv">e</span><span class="o">+</span>
<span class="o">&gt;</span> <span class="nv">ERROR</span>:        <span class="mi">5010</span> <span class="nv">Bad</span> <span class="nv">real</span> <span class="nv">number</span> <span class="nv">in</span> <span class="nv">item</span> <span class="mi">1</span> <span class="nv">of</span> <span class="nv">list</span> <span class="nv">input</span>
<span class="o">&gt;</span>  <span class="nv">ERROR</span> <span class="k">for</span> <span class="mi">1</span><span class="nv">e</span><span class="o">+</span>           <span class="o">-</span><span class="mi">4</span> :<span class="nv">missing</span> <span class="nv">exponent</span> <span class="nv">after</span> <span class="nv">sign</span>
<span class="o">&gt;</span><span class="mi">1</span><span class="nv">e</span><span class="o">+</span><span class="mi">2</span>.<span class="mi">0</span>
<span class="o">&gt;</span> <span class="nv">ERROR</span>:        <span class="mi">5010</span> <span class="nv">Bad</span> <span class="nv">real</span> <span class="nv">number</span> <span class="nv">in</span> <span class="nv">item</span> <span class="mi">1</span> <span class="nv">of</span> <span class="nv">list</span> <span class="nv">input</span>
<span class="o">&gt;</span>  <span class="nv">ERROR</span> <span class="k">for</span> <span class="mi">1</span><span class="nv">e</span><span class="o">+</span><span class="mi">2</span>.<span class="mi">0</span>           <span class="o">-</span><span class="mi">5</span> :<span class="nv">bad</span> <span class="nv">number</span>
</code></pre></div>

<h2 id="author">AUTHOR</h2>
<div class="codehilite"><pre><span></span><code>John S. Urban
</code></pre></div>

<h2 id="license">LICENSE</h2>
<div class="codehilite"><pre><span></span><code>Public Domain
</code></pre></div>
    

    <h3>Arguments</h3>
    
      
<table class="table table-striped varlist">
<thead><tr><th>Type</th>
<th>Intent</th><th>Optional</th>
<th>Attributes</th><th></th><th>Name</th><th></th></thead>



<tbody>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-string~4"></span>character(len=*),</td>
  <td>intent(in)</td>
  <td></td>
  
  <td></td><td>::</td>
  <td><strong>string</strong></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-msg"></span>character(len=:),</td>
  <td>intent(out),</td>
  <td>optional</td>
  
  <td>allocatable</td><td>::</td>
  <td><strong>msg</strong></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-verbose"></span>logical,</td>
  <td>intent(in),</td>
  <td>optional</td>
  
  <td></td><td>::</td>
  <td><strong>verbose</strong></td><td></td>
  
</tr>

</tbody>
</table>

    
    
    
    
    
    
    
   <h3>Return Value <small><span class="anchor" id="variable-isnumber"></span>integer
  </small></h3>
    
    
    
    
     
    <br>

    <section class="visible-xs visible-sm hidden-md">
      
<h3>Contents</h3>
 



<div class="panel panel-primary">
  <div class="panel-heading text-left"><h3 class="panel-title"><a data-toggle="collapse" href="#vars-1">Variables</a></h3></div>
  <div id="vars-1" class="panel-collapse collapse">
    <div class="list-group">
      
      <a class="list-group-item" href="../proc/isnumber.html#variable-founddigit">founddigit</a>
      
      <a class="list-group-item" href="../proc/isnumber.html#variable-i~10">i</a>
      
      <a class="list-group-item" href="../proc/isnumber.html#variable-iend~2">iend</a>
      
      <a class="list-group-item" href="../proc/isnumber.html#variable-message">message</a>
      
      <a class="list-group-item" href="../proc/isnumber.html#variable-verbose_local">verbose_local</a>
      
      <a class="list-group-item" href="../proc/isnumber.html#variable-z">z</a>
      
    </div>
  </div>
</div>













<div class="panel panel-primary">
  <div class="panel-heading text-left"><h3 class="panel-title"><a data-toggle="collapse" href="#subs-1">Subroutines</a></h3></div>
  <div class="list-group">
    <div id="subs-1" class="panel-collapse collapse">
      
      <a class="list-group-item" href="../proc/isnumber.html#proc-next">next</a>
      
    </div>
  </div>
</div>









<div class="panel panel-primary">
  <div class="panel-heading text-left"><h3 class="panel-title">Source Code</h3></div>
  <div class="list-group">
    <a class="list-group-item" href="../proc/isnumber.html#src">isNumber</a>
  </div>
</div>



    </section>
    <br class="visible-xs visible-sm hidden-md">

    

    
    <section>    
      <h2>Variables</h2>
    
<table class="table table-striped varlist">
<thead><tr><th>Type</th><th>Visibility</th>

<th>Attributes</th><th></th><th>Name</th><th></th><th>Initial</th><th></th></thead>



<tbody>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-founddigit"></span>logical,</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>founddigit</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-i~10"></span>integer,</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>i</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-iend~2"></span>integer,</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>iend</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-message"></span>character(len=:),</td>
  
  <td>public,</td>
  <td>allocatable</td><td>::</td>
  <td><strong>message</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-verbose_local"></span>logical,</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>verbose_local</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-z"></span>character(len=1),</td>
  
  <td>public,</td>
  <td>allocatable</td><td>::</td>
  <td><strong>z</strong>(:)</td><td></td><td></td><td></td>
  
</tr>

</tbody>
</table>

    </section>
    <br>
    
    
    
    
    

    
    
    
    
    


    
    <section>
    <h2>Subroutines</h2>
    
    
  <div class="panel panel-default">
  <div class="panel-heading codesum"><span class="anchor" id="proc-next"></span><h3>
subroutine next()
    
    
   
</h3></div>
  <div class="panel-body">
       
    
    
    <h4>Arguments</h4>
    
      <em>None</em>
    
    

  </div>
  </div>

    
    </section>    
    
    
    
    <section>
    <h2><span class="anchor" id="src"></span>Source Code</h2>
    <div class="highlight"><pre><span></span><span class="k">function </span><span class="n">isNumber</span><span class="p">(</span><span class="n">string</span><span class="p">,</span><span class="n">msg</span><span class="p">,</span><span class="n">verbose</span><span class="p">)</span>
<span class="k">implicit none</span>

<span class="c">! ident_51=&quot;@(#)M_strings::isnumber(3f): Determines if a string is a number of not.&quot;</span>

<span class="kt">character</span><span class="p">(</span><span class="nb">len</span><span class="o">=*</span><span class="p">),</span><span class="k">intent</span><span class="p">(</span><span class="n">in</span><span class="p">)</span>    <span class="kd">::</span> <span class="n">string</span>
<span class="kt">character</span><span class="p">(</span><span class="nb">len</span><span class="o">=</span><span class="p">:),</span><span class="k">intent</span><span class="p">(</span><span class="n">out</span><span class="p">),</span><span class="k">allocatable</span><span class="p">,</span><span class="k">optional</span> <span class="kd">::</span> <span class="n">msg</span>
<span class="kt">logical</span><span class="p">,</span><span class="k">intent</span><span class="p">(</span><span class="n">in</span><span class="p">),</span><span class="k">optional</span>                      <span class="kd">::</span> <span class="n">verbose</span>
<span class="kt">integer</span>                      <span class="kd">::</span> <span class="n">isnumber</span>

<span class="kt">integer</span>             <span class="kd">::</span> <span class="n">i</span><span class="p">,</span><span class="n">iend</span>
<span class="kt">character</span><span class="p">(</span><span class="nb">len</span><span class="o">=</span><span class="mi">1</span><span class="p">),</span><span class="k">allocatable</span> <span class="kd">::</span> <span class="n">z</span><span class="p">(:)</span>
<span class="kt">character</span><span class="p">(</span><span class="nb">len</span><span class="o">=</span><span class="p">:),</span><span class="k">allocatable</span> <span class="kd">::</span> <span class="n">message</span>
<span class="kt">logical</span>                      <span class="kd">::</span> <span class="n">founddigit</span>
<span class="kt">logical</span>                      <span class="kd">::</span> <span class="n">verbose_local</span>

   <span class="n">i</span><span class="o">=</span><span class="mi">1</span>
   <span class="n">founddigit</span><span class="o">=</span><span class="p">.</span><span class="n">false</span><span class="p">.</span>
   <span class="n">isnumber</span><span class="o">=</span><span class="mi">0</span>
   <span class="n">z</span><span class="o">=</span><span class="n">switch</span><span class="p">(</span><span class="nb">trim</span><span class="p">(</span><span class="n">nospace</span><span class="p">(</span><span class="n">string</span><span class="p">)))</span>
   <span class="n">iend</span><span class="o">=</span><span class="n">size</span><span class="p">(</span><span class="n">z</span><span class="p">)</span>
   <span class="n">message</span><span class="o">=</span><span class="s1">&#39;not a number&#39;</span>
   <span class="k">if</span><span class="p">(</span><span class="nb">present</span><span class="p">(</span><span class="n">verbose</span><span class="p">))</span><span class="k">then</span>
<span class="k">      </span><span class="n">verbose_local</span><span class="o">=</span><span class="n">verbose</span>
   <span class="k">else</span>
<span class="k">      </span><span class="n">verbose_local</span><span class="o">=</span><span class="p">.</span><span class="n">false</span><span class="p">.</span>
   <span class="k">endif</span>
<span class="k">   </span><span class="n">DONE</span> <span class="p">:</span> <span class="k">block</span>
<span class="k">      if</span><span class="p">(</span><span class="n">iend</span><span class="p">.</span><span class="n">eq</span><span class="p">.</span><span class="mi">0</span><span class="p">)</span><span class="k">then</span>
<span class="k">         </span><span class="n">isnumber</span><span class="o">=-</span><span class="mi">1</span>                   <span class="c">! string is null</span>
         <span class="n">message</span><span class="o">=</span><span class="s1">&#39;null string&#39;</span>
         <span class="k">exit </span><span class="n">DONE</span>
      <span class="k">endif</span>

<span class="k">      if</span><span class="p">(</span><span class="nb">index</span><span class="p">(</span><span class="s1">&#39;+-&#39;</span><span class="p">,</span><span class="n">z</span><span class="p">(</span><span class="n">i</span><span class="p">)).</span><span class="n">ne</span><span class="p">.</span><span class="mi">0</span><span class="p">)</span> <span class="n">i</span><span class="o">=</span><span class="n">i</span><span class="o">+</span><span class="mi">1</span>  <span class="c">! skip optional leading sign</span>
      <span class="k">if</span><span class="p">(</span><span class="n">i</span><span class="p">.</span><span class="n">gt</span><span class="p">.</span><span class="n">iend</span><span class="p">)</span><span class="k">then</span>
<span class="k">         </span><span class="n">isnumber</span><span class="o">=-</span><span class="mi">2</span>                   <span class="c">! string was just a sign</span>
         <span class="n">message</span><span class="o">=</span><span class="s1">&#39;just a sign&#39;</span>
         <span class="k">exit </span><span class="n">DONE</span>
      <span class="k">endif</span>

<span class="k">      call </span><span class="n">next</span><span class="p">()</span>                      <span class="c">! position I to next non-digit or end of string+1</span>

      <span class="k">if</span><span class="p">(</span><span class="n">i</span><span class="p">.</span><span class="n">gt</span><span class="p">.</span><span class="n">iend</span><span class="p">)</span><span class="k">then</span>
<span class="k">         </span><span class="n">isnumber</span><span class="o">=</span><span class="mi">1</span>                    <span class="c">! [+-]NNNNNN</span>
         <span class="n">message</span><span class="o">=</span><span class="s1">&#39;integer&#39;</span>
         <span class="k">exit </span><span class="n">DONE</span>
      <span class="k">endif</span>
<span class="k">      if</span><span class="p">(</span><span class="n">z</span><span class="p">(</span><span class="n">i</span><span class="p">).</span><span class="n">eq</span><span class="p">.</span><span class="s1">&#39;.&#39;</span><span class="p">)</span><span class="k">then</span>              <span class="c">! a period would be OK at this point</span>
         <span class="n">i</span><span class="o">=</span><span class="n">i</span><span class="o">+</span><span class="mi">1</span>
      <span class="k">endif</span>

<span class="k">      if</span><span class="p">(</span><span class="n">i</span><span class="p">.</span><span class="n">gt</span><span class="p">.</span><span class="n">iend</span><span class="p">)</span><span class="k">then</span>                <span class="c">! [+-]NNNNNN.</span>
         <span class="n">isnumber</span><span class="o">=</span><span class="mi">2</span>
         <span class="n">message</span><span class="o">=</span><span class="s1">&#39;whole number&#39;</span>
         <span class="k">exit </span><span class="n">DONE</span>
      <span class="k">endif</span>

<span class="k">      call </span><span class="n">next</span><span class="p">()</span>                      <span class="c">! position I to next non-digit or end of string+1</span>
      <span class="k">if</span><span class="p">(</span><span class="n">i</span><span class="p">.</span><span class="n">gt</span><span class="p">.</span><span class="n">iend</span><span class="p">)</span><span class="k">then</span>
<span class="k">         </span><span class="n">isnumber</span><span class="o">=</span><span class="mi">3</span>                    <span class="c">! [+-]NNNNNN.MMMM</span>
         <span class="n">message</span><span class="o">=</span><span class="s1">&#39;real number&#39;</span>
         <span class="k">exit </span><span class="n">DONE</span>
      <span class="k">endif</span>

<span class="k">      if</span><span class="p">(</span><span class="nb">index</span><span class="p">(</span><span class="s1">&#39;eEdD&#39;</span><span class="p">,</span><span class="n">z</span><span class="p">(</span><span class="n">i</span><span class="p">)).</span><span class="n">ne</span><span class="p">.</span><span class="mi">0</span><span class="p">)</span><span class="k">then</span>
<span class="k">         </span><span class="n">i</span><span class="o">=</span><span class="n">i</span><span class="o">+</span><span class="mi">1</span>
         <span class="k">if</span><span class="p">(</span><span class="n">i</span><span class="p">.</span><span class="n">eq</span><span class="p">.</span><span class="mi">2</span><span class="p">)</span><span class="k">then</span>
<span class="k">            </span><span class="n">isnumber</span><span class="o">=-</span><span class="mi">6</span>                   <span class="c">! [+-]NNNNNN[.[MMMM]]e but a value must follow</span>
            <span class="n">message</span><span class="o">=</span><span class="s1">&#39;missing leading value before exponent&#39;</span>
            <span class="k">exit </span><span class="n">DONE</span>
         <span class="k">endif</span>
<span class="k">      endif</span>
<span class="k">      if</span><span class="p">(</span><span class="n">i</span><span class="p">.</span><span class="n">gt</span><span class="p">.</span><span class="n">iend</span><span class="p">)</span><span class="k">then</span>
<span class="k">         </span><span class="n">isnumber</span><span class="o">=-</span><span class="mi">3</span>                   <span class="c">! [+-]NNNNNN[.[MMMM]]e but a value must follow</span>
         <span class="n">message</span><span class="o">=</span><span class="s1">&#39;missing exponent&#39;</span>
         <span class="k">exit </span><span class="n">DONE</span>
      <span class="k">endif</span>
<span class="k">      if</span><span class="p">(.</span><span class="nb">not</span><span class="p">.</span><span class="n">founddigit</span><span class="p">)</span><span class="k">then</span>
<span class="k">         </span><span class="n">isnumber</span><span class="o">=-</span><span class="mi">7</span>
         <span class="n">message</span><span class="o">=</span><span class="s1">&#39;missing value before exponent&#39;</span>
         <span class="k">exit </span><span class="n">DONE</span>
      <span class="k">endif</span>
<span class="k">      if</span><span class="p">(</span><span class="nb">index</span><span class="p">(</span><span class="s1">&#39;+-&#39;</span><span class="p">,</span><span class="n">z</span><span class="p">(</span><span class="n">i</span><span class="p">)).</span><span class="n">ne</span><span class="p">.</span><span class="mi">0</span><span class="p">)</span> <span class="n">i</span><span class="o">=</span><span class="n">i</span><span class="o">+</span><span class="mi">1</span>
      <span class="k">if</span><span class="p">(</span><span class="n">i</span><span class="p">.</span><span class="n">gt</span><span class="p">.</span><span class="n">iend</span><span class="p">)</span><span class="k">then</span>
<span class="k">         </span><span class="n">isnumber</span><span class="o">=-</span><span class="mi">4</span>                   <span class="c">! [+-]NNNNNN[.[MMMM]]e[+-] but a value must follow</span>
         <span class="n">message</span><span class="o">=</span><span class="s1">&#39;missing exponent after sign&#39;</span>
         <span class="k">exit </span><span class="n">DONE</span>
      <span class="k">endif</span>
<span class="k">      call </span><span class="n">next</span><span class="p">()</span>                      <span class="c">! position I to next non-digit or end of string+1</span>
      <span class="k">if</span><span class="p">(</span><span class="n">i</span><span class="p">.</span><span class="n">gt</span><span class="p">.</span><span class="n">iend</span><span class="p">)</span><span class="k">then</span>
<span class="k">         </span><span class="n">isnumber</span><span class="o">=</span><span class="mi">4</span>                    <span class="c">! [+-]NNNNNN.MMMMe[+-]LL</span>
         <span class="n">message</span><span class="o">=</span><span class="s1">&#39;value with exponent&#39;</span>
         <span class="k">exit </span><span class="n">DONE</span>
      <span class="k">endif</span>
<span class="k">      </span><span class="n">isnumber</span><span class="o">=-</span><span class="mi">5</span>
      <span class="n">message</span><span class="o">=</span><span class="s1">&#39;bad number&#39;</span>
   <span class="k">endblock </span><span class="n">DONE</span>
   <span class="k">if</span><span class="p">(</span><span class="n">verbose_local</span><span class="p">)</span><span class="k">then</span>
<span class="k">      write</span><span class="p">(</span><span class="o">*</span><span class="p">,</span><span class="o">*</span><span class="p">)</span><span class="nb">trim</span><span class="p">(</span><span class="n">string</span><span class="p">)</span><span class="o">//</span><span class="s1">&#39; is &#39;</span><span class="o">//</span><span class="n">message</span>
   <span class="k">endif</span>
<span class="k">   if</span><span class="p">(</span><span class="nb">present</span><span class="p">(</span><span class="n">msg</span><span class="p">))</span><span class="k">then</span>
<span class="k">      </span><span class="n">msg</span><span class="o">=</span><span class="n">message</span>
   <span class="k">endif</span>

<span class="k">contains</span>
<span class="k">   subroutine </span><span class="n">next</span><span class="p">()</span> <span class="c">! move to next non-digit or end of string+1</span>
      <span class="kt">integer</span> <span class="kd">::</span> <span class="n">j</span>
      <span class="k">do </span><span class="n">j</span><span class="o">=</span><span class="n">i</span><span class="p">,</span><span class="n">iend</span>
         <span class="k">if</span><span class="p">(.</span><span class="nb">not</span><span class="p">.</span><span class="n">isdigit</span><span class="p">(</span><span class="n">z</span><span class="p">(</span><span class="n">j</span><span class="p">)))</span><span class="k">then</span>
<span class="k">            exit</span>
<span class="k">         endif</span>
<span class="k">         </span><span class="n">founddigit</span><span class="o">=</span><span class="p">.</span><span class="n">true</span><span class="p">.</span>
         <span class="k">if</span><span class="p">(</span><span class="n">verbose_local</span><span class="p">)</span> <span class="k">write</span><span class="p">(</span><span class="o">*</span><span class="p">,</span><span class="o">*</span><span class="p">)</span><span class="s1">&#39;I=&#39;</span><span class="p">,</span><span class="n">i</span><span class="p">,</span><span class="s1">&#39; J=&#39;</span><span class="p">,</span><span class="n">j</span><span class="p">,</span><span class="s1">&#39; Z(j)=&#39;</span><span class="p">,</span><span class="n">z</span><span class="p">(</span><span class="n">j</span><span class="p">)</span>
      <span class="k">enddo</span>
<span class="k">      </span><span class="n">i</span><span class="o">=</span><span class="n">j</span>
      <span class="k">if</span><span class="p">(</span><span class="n">verbose_local</span><span class="p">)</span><span class="k">then</span>
<span class="k">         write</span><span class="p">(</span><span class="o">*</span><span class="p">,</span><span class="o">*</span><span class="p">)</span><span class="s1">&#39;I and J=&#39;</span><span class="p">,</span><span class="n">i</span>
         <span class="k">if</span><span class="p">(</span><span class="n">i</span><span class="p">.</span><span class="n">le</span><span class="p">.</span><span class="n">iend</span><span class="p">)</span> <span class="k">then</span>
<span class="k">            write</span><span class="p">(</span><span class="o">*</span><span class="p">,</span><span class="o">*</span><span class="p">)</span><span class="s1">&#39;Z(I)=&#39;</span><span class="p">,</span><span class="n">z</span><span class="p">(</span><span class="n">i</span><span class="p">)</span>
         <span class="k">else</span>
<span class="k">            write</span><span class="p">(</span><span class="o">*</span><span class="p">,</span><span class="o">*</span><span class="p">)</span><span class="s1">&#39;====&gt;&#39;</span>
         <span class="k">endif</span>
<span class="k">      endif</span>
<span class="k">   end subroutine </span><span class="n">next</span>
<span class="k">end function </span><span class="n">isNumber</span>
</pre></div>

    </section>
    <br>
    
    
    </div>
  </div>


    <hr>    
    </div> <!-- /container -->
    <footer>
      <div class="container">
      <div class="row">
        <div class="col-xs-6 col-md-4"><p>&copy; 2022 
                                          </p></div>
        <div class="col-xs-6 col-md-4 col-md-push-4">
          <p class="text-right">
            Documentation generated by 
            <a href="https://github.com/cmacmackin/ford">FORD</a>
             on 2022-01-16 22:32  
          </p>
        </div>
        <div class="col-xs-12 col-md-4 col-md-pull-4"><p class="text-center"> M_strings was developed by John S. Urban</p></div>
      </div>
      <br>
      </div> <!-- /container -->    
    </footer>

    <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
<!--
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
-->
    <script src="../js/bootstrap.min.js"></script>
    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <script src="../js/ie10-viewport-bug-workaround.js"></script>

    <!-- MathJax JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script type="text/x-mathjax-config">
      MathJax.Hub.Config({
        TeX: { extensions: ['AMSmath.js','AMSsymbols.js','noErrors.js','noUndefined.js'], equationNumbers: { autoNumber: 'AMS' } },
        jax: ['input/TeX','input/MathML','output/HTML-CSS'],
        extensions: ['tex2jax.js','mml2jax.js','MathMenu.js','MathZoom.js']
      });
    </script>
    
    <script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
    
    
    <script src="../tipuesearch/tipuesearch_content.js"></script>
    <script src="../tipuesearch/tipuesearch_set.js"></script>
    <script src="../tipuesearch/tipuesearch.js"></script>
    
    
  </body>
</html>